/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import Model.HouseListBean;
import dao.HouseListDAO;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.model.SelectItem;

/**
 *
 * @author amkreuz
 */
@Named(value = "householdListController")
@SessionScoped
public class HouseholdListController implements Serializable {

    private HouseListBean houseListBean;

    public HouseListBean getHouseListBean() {
        return houseListBean;
    }

    public void setHouseListBean(HouseListBean houseListBean) {
        this.houseListBean = houseListBean;
    }

    /**
     * Creates a new instance of HouseholdListContrller
     */
    public HouseholdListController() 
    {

    }
    
    public List<SelectItem> getHouseList() {
        try {
            HouseListDAO.init();
            List<SelectItem> l = HouseListDAO.getHouseList();
            HouseListDAO.terminate();
            return l;
        } catch (SQLException ex) {
            Logger.getLogger(HouseholdListController.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
}